<div class="table-condensed" style="overflow-y: auto;overflow-x: auto;width: 100%;height: 700px">
    <table class="table table-hover table-striped table-bordered text-center">
        <tr>
            <th class="text-center">序号</th>
            <th class="text-center">姓名</th>
            <th class="text-center">手机号</th>
            <th class="text-center">省份证号码</th>
            <th class="text-center">装机住址</th>
            <th class="text-center">推荐人</th>
            <th class="text-center">预约日期</th>
            <th class="text-center">套餐类型</th>
            <th class="text-center">套餐价格</th>
            <th class="text-center">状态</th>
            <th class="text-center">操作</th>
        </tr>
        <volist name="order_list" id="item">
            <tr>
                <td>{$item['id']}</td>
                <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis">{$item['name']}</td>
                <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis">{$item['phone']}</td>
                <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis">{$item['id_card']}</td>
                <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis">{$item['address']}</td>
                <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis">{$item['referrer']}</td>
                <td>{$item['order_date']|date="Y-m-d",###}</td>
                <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis">{$item['good_name']}</td>
                <td>{$item['good_price']}</td>
                <td>{$item['status']?'已处理':'未处理'}</td>
                <td>
                    <if condition="$item['status'] eq 1">
                        <input type="button" disabled="disabled" style="text-decoration: none;color: red" value="已处理">
                        <else />
                        <input type="button" name="deal" value="待处理">
                    </if>
                    <input type="button" name="order_info" value="详情">
                    <input type="button" name="order_delete" style="color: darkred" value="删除">
                </td>
            </tr>
        </volist>
    </table>
</div>
<script>
    //处理订单
    $(document).ready(function () {
        $("input[name='deal']").click(function () {
            console.log('deal');
            var obj = $(this).parent().parent();
            var id = obj.children("td:first-child").text();
            console.log('id: '+id);
            $.ajax({
                url: '/admin.php/Order/preDoneOrder/id/'+id,
                method:'get',
                dataType:'json',
                success: function (res) {
                    if (res.code == 200) {
                        $("#order-page").empty();
                        $("#order-page").append(res.data);
                    }
                }
            });
        });
    });
    //查看详情
    $(document).ready(function () {
        $("input[name='order_info']").click(function () {
            var obj = $(this).parent().parent();
            var id = obj.children("td:first-child").text();
            console.log('id: '+id);
            $.ajax({
                url: '/admin.php/Order/getOrderInfo/id/'+id,
                method:'get',
                dataType:'json',
                success: function (res) {
                    if (res.code == 200) {
                        $("#order-page").empty();
                        $("#order-page").append(res.data);
                    }
                }
            });
        });
    });
    //删除
    $(document).ready(function () {
        $("input[name='order_delete']").click(function () {
            var obj = $(this).parent().parent();
            var id = obj.children("td:first-child").text();
            console.log('id: '+id);
            var r = confirm('确认删除吗？');
            if (r == true) {
                $.ajax({
                    url: '/admin.php/order/deleteOrder/orderId/'+id,
                    dataType:'json',
                    success: function (res) {
                        if (res.code == 200) {
                            alert("删除成功");
                            obj.hide(500);
                        } else {
                            alert('删除失败');
                        }
                    }
                });
            }
        });
    });
</script>